from django.conf.urls import url
from users import views

from rest_framework_jwt.views import obtain_jwt_token
from .views import AddressViewSet
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'addresses', AddressViewSet, base_name='address')
urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.RegisterUsernameCountAPIView.as_view(),
        name='usernamecount'),
    url(r'^phones/(?P<mobile>1[345789]\d{9})/count/$', views.RegisterMoblieCountAPIView.as_view()),
    url(r'^$', views.RegisterCreateView.as_view()),
    # url(r'^auths/', obtain_jwt_token),
    url(r'^auths/', views.UserAuthorizationView.as_view()),
    url(r'^infos/$', views.UserDetailView.as_view()),
    # PUT /users/emails/
    url(r'^emails/$', views.EmailView.as_view(), name='send_mail'),
    # /users/emails/verification/
    url(r'^emails/verification/$', views.VerificationEmailView.as_view()),
    # # POST    /users/browerhistories/       {'sku_id':xxx}  新增历史记录
    # url(r'^browerhistories$',views.UserHistoryView.as_view())
    # 少了/
    # /users/browerhistories/
    url(r'^browerhistories/$', views.UserHistoryView.as_view()),
]

urlpatterns += router.urls
